xtrace "poly-sphere" { procedure psph l,m,n, r, pn,pn2 { nvar pn=16; nvar pn2=int (pn/2); nvar h=r; var t1,t2; var c1,c2,s1,s2; var r1,r2,z1,z2; var x1,y1,x2,y2,x3,y3,x4,y4; para l,m,n; sim r,r,h; boundary sphere 0,0,0, 1 { var i,j; j=0; while lt (j - pn2) { t1=PI*j/pn2; t2=PI*(j + 1)/pn2; z1=cos (t1); r1=sin (t1); z2=cos (t2); r2=sin (t2); i=0; while lt (i - pn) { t1=2*PI*i/pn; t2=2*PI*(i + 1)/pn; c1=cos (t1); s1=sin (t1); c2=cos (t2); s2=sin (t2); x1=r1*c1; y1=r1*s1; x2=r1*c2; y2=r1*s2; x3=r2*c1; y3=r2*s1; x4=r2*c2; y4=r2*s2; poly { pt x1,y1,z1; pt x2,y2,z1; pt x4,y4,z2; pt x3,y3,z2; } i=i + 1; } j=j + 1; } } } }